<template>
	<view class="index">
		<view class="mine-main-head">
			<view class="jibie color_fff">
				投资级别: {{userinfo.level_value||'无'}}
			</view>
			<view class="jine color_fff" v-if="yueinfo[0]">
				{{yueinfo[0].coin_value}}U
			</view>
			<view class="bordersss display_flex flex_between" v-if="yueinfo[1]">
				<view class="bordersssview" style="border-right: 2upx solid #FFFFFF">
					<view>{{yueinfo[1].coin_name}}</view>
					<view class="">{{yueinfo[1].coin_value}}</view>
				</view>
				<view class="bordersssview" style="border-right: 2upx solid #FFFFFF">
					<view>{{yueinfo[2].coin_name}}</view>
					<view class="">{{yueinfo[2].coin_value}}</view>
				</view>
				<view class="bordersssview">
					<view>{{yueinfo[3].coin_name}}</view>
					<view class="">{{yueinfo[3].coin_value}}</view>
				</view>
			</view>
		</view>
		<view class="jiange"></view>
		<view class="tudndui display_flex flex_start" @click="clickMenu(`/pages/index/tuandui/tuandui?name=${userinfo.user_nick_name}`)">
			<view class="">
				<image class="touxiang" src="/static/img/s14.png" mode=""></image>
			</view>
			<view class="tuandui">
				<view class="">{{userinfo.user_nick_name}}的团队</view>
				<view class="" style="padding-top: 50upx;text-align: left;">
					<image src="/static/img/s13.png" mode="" style="margin-right: 30upx;"></image>
					<text style="position: relative;top: -6upx;">{{teamCount}}</text>
				</view>
			</view>
		</view>
		<u-notice-bar style="width: 92%;margin: 0 auto;" border-radius="30" mode="vertical" :duration="3000" type="none"
		 color="#FF0000" bg-color="#f5f5f5" :list="list"></u-notice-bar>
		<view class="juanzeng display_flex flex_between">
			<view class="display_flex flex_start">
				<image class="touxiang1" src="/static/img/s15.png" mode=""></image>
				<view class="" style="line-height: 100upx;margin-left: 30upx;font-weight: 600;">
					乐施募捐
				</view>
			</view>
			<view class="display_flex flex_start">
				<view class="chongzhi" @click="clickMenu('/pages/index/mujuanj/mujuanj')">捐款</view>
				<view class="tixian" @click="clickMenu('/pages/index/mujuan/mujuan')">明细</view>
			</view>
		</view>



		<view class="juanzeng ">
			<view class="display_flex flex_between">
				<view class="yasen">
					新闻
				</view>
				<view class="yasen1" @click="tiaozhuan">
					更多>
				</view>
			</view>
			<view class="box" @click="navgopages(i)" v-for="(i,index) in newsList" :key="index">
				<view class="biaoti color_222 font_size_30 over_one">
					{{i.news_title}}
				</view>
				<view class="color_9B9B9B font_size_28 over_one">
					{{i.news_text}}
				</view>
				<view class="color_9B9B9B font_size_28">
					{{i.create_time}}
				</view>

			</view>
		</view>














	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				userinfo: {},
				newsList: [{
					news_title: '请注意，内有猛犬！BigONE带你一文读懂SHIB柴犬币',
					news_text: '最近几天一种名为“柴犬币”（SHIB），也俗称“屎币”的虚拟货币，以单日涨幅超过 5 倍，月涨幅超过 300 倍，',
					create_time: '2021-05-14 16:02',
					url:'https://m.mytokencap.com/news/236355?language=zh_CN&legal_currency=CNY'
				},
				{
					news_title: '行业观察 | shib暴涨后刹车，大波动币种注意风险',
					news_text: '最近火热的shib（柴犬币），让人惊叹，短短2天时间，Shib先后上线了OKEx、火币、币安三大交易所，币价也真的抹掉了一个“0”，越过狗狗币，',
					create_time: '2021-05-17 15:37',
					url:'https://m.mytokencap.com/news/239279?language=zh_CN&legal_currency=CNY'
				}],
				teamCount: '',
				yueinfo: {},


			}
		},

		onShow() {

			if (uni.getStorageSync('rescodeUserInfo').user_id) {
				this.userdetail()

			} else {
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}

		},
		methods: {
			jiequ(num, decimal) {
				num = num.toString()
				let index = num.indexOf('.')
				if (index !== -1) {
					num = num.substring(0, decimal + index + 1)
				} else {
					num = num.substring(0)
				}
				return parseFloat(num).toFixed(decimal)
			},
			// 初始化方法
			async systemnotice() {
				let data = {

				}
				const res = await this.$appserve.systemnotice(data);
				//console.log(res)
				this.list.push(res.data.system_notice)

			},
			// 初始化方法
			async userwallet() {
				let data = {
					user_id: uni.getStorageSync('rescodeUserInfo').user_id
				}
				const res = await this.$appserve.userwallet(data);
				//console.log(res)
				res.data.forEach((item) => {
					// if(item.coin_name == 'USDT'){

					// }
					item.coin_value = this.jiequ(item.coin_value, 2)
				})
				this.yueinfo = res.data

			},
			// 初始化方法
			async myteamcount() {
				let data = {
					user_id: uni.getStorageSync('rescodeUserInfo').user_id
				}
				const res = await this.$appserve.myteamcount(data);
				//console.log(res)
				this.teamCount = res.data.teamCount

			},
			tiaozhuan() {
				uni.switchTab({
					url: '../zixun/index'
				})
			},
			clickMenu(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 初始化方法
			async news() {
				let data = {

				}
				const res = await this.$appserve.news(data);
				//console.log(res)
				this.newsList = res.data.slice(0, 2)

			},
			navgopages(i) {
				uni.setStorageSync("xinwen", i)
				uni.navigateTo({
					url: "../news/newdel/newdel"
				})
			},

			// 用户详情
			async userdetail() {
				let data = {
					user_id: uni.getStorageSync('rescodeUserInfo').user_id
				}
				const res = await this.$appserve.userdetail(data);
				console.log(res)
				this.userinfo = res.data
				if (res.code == 0) {
					this.myteamcount()
					this.userwallet()
					this.systemnotice()
					// this.news()
				}


			},

		}
	}
</script>
<style>
	page {
		background-color: #fff !important;
	}
</style>
<style lang="less" scoped>
	.bordersssview {
		width: calc(100% / 3);
	}

	.box {
		width: 100%;
		background: #FFFFFF;
		border-radius: 3px;
		padding: 10upx 0;
		margin: 20upx auto;
		border-top: 2upx solid #eee;
	}

	.box view {
		line-height: 60upx;
	}

	.biaoti {
		font-weight: 600;
	}

	.yasen {
		border-left: 8upx solid #6BCF00;
		height: 30upx;
		line-height: 30upx;
		padding-left: 10upx;

	}

	.yasen1 {
		height: 30upx;
		line-height: 30upx;
		padding-left: 10upx;
	}

	.chongzhi {
		/* FF775F  FF5050  */
		background: linear-gradient(10deg, #FF775F 0%, #FF5050 100%);
		border-radius: 30upx;
		color: #ffffff;
		font-size: 30upx;
		font-weight: 500;
		text-align: center;
		box-shadow: 5upx 5upx 10upx #FF775F;
		margin-right: 20upx;
		padding: 10upx 30upx;
		height: 60upx;
		position: relative;
		top: 20upx;
	}

	.tixian {
		background: linear-gradient(10deg, #6BCF00 0%, #73DE00 100%);
		border-radius: 30upx;
		color: #ffffff;
		font-size: 30upx;
		font-weight: 500;
		text-align: center;
		box-shadow: 5upx 5upx 10upx #73DE00;
		padding: 10upx 30upx;
		height: 60upx;
		position: relative;
		top: 20upx;
	}

	.juanzeng {
		width: 92%;
		margin: 30upx auto;
		padding: 20upx;
		background-color: #ffff;
		box-shadow: 5upx 5upx 10upx #f5f5f5;
		border-radius: 10upx;

	}

	.tuandui {
		color: #fff;
		padding-top: 60upx;

		image {
			width: 28upx;
			height: 30upx;
		}
	}

	.touxiang {
		width: 128upx;
		height: 128upx;
		padding: 60upx 30upx 0 60upx;
	}

	.touxiang1 {
		width: 100upx;
		height: 100upx;
	}

	.tudndui {
		background: url("") no-repeat;
		background-size: 100%;
		height: 280upx;
		padding: 0.1px;
		position: relative;
		margin: 0 auto;
		text-align: center;
	}

	.jiange {
		width: 100%;
		height: 20upx;
		background-color: #F7F7F7;
		margin-top: -2upx;
	}

	.bordersss {
		position: absolute;
		bottom: 0;
		width: 100%;
		padding: 20upx;
		color: #fff;
		border-top: 2upx solid #FFFFFF;
	}


	.jibie {
		font-size: 36upx;
		font-family: Helvetica;
		color: #FFFFFF;
		padding-top: 60upx;
	}

	.jine {
		font-size: 92upx;
		font-family: LiGothicMed;
		color: #FFFFFF;
	}

	.houjia_dengji {
		width: 100upx;
		height: 50upx;
		margin-left: 20upx;
	}

	.mine-main-head {
		background: url("") no-repeat;
		width: 90%;
		background-size: 100%;
		height: 400upx;
		padding: 0.1px;
		position: relative;
		margin: 0 auto;
		text-align: center;
	}
</style>
